package models

import (
	"CMETO/utils"
	"time"
)

type Department struct {
	// 部门id
	Id int `json:"id" gorm:"column:id;type:int;auto_increment;primary_key;"`
	// 所属部门
	Fid int `json:"fid" gorm:"column:fid;type:int;"`
	// 部门名称
	Name string `json:"name" gorm:"column:name;type:varchar(30);"`
	// 负责人Id
	LeaderId int `json:"leader_id" gorm:"column:leader_id;type:int;"`
	// 创建时间
	CreateTime string `json:"create_time" gorm:"column:create_time;type:varchar(30);"`
	// 部门状态
	Status int `json:"status" gorm:"column:status;type:int;"`
	// 部门描述
	Description string `json:"description" gorm:"column:description;type:varchar(120);"`
	// 删除标记
	IsDelete int `json:"is_delete" gorm:"column:is_delete;type:int;"`
	// 子部门
	Children []Department `json:"children" gorm:"foreignKey:fid;"`
	// 用户
	Users []User `json:"users"  gorm:"foreignKey:Department;"`
}

func InsertMockDepartment() {
	DB.Model(&Department{}).Create([]Department{
		{Fid: 0, Name: "行政部", CreateTime: utils.TimeFormatter(time.Now()), LeaderId: 0, Status: 1, Description: "行政部", IsDelete: 0},
		{Fid: 0, Name: "市场部", CreateTime: utils.TimeFormatter(time.Now()), LeaderId: 0, Status: 1, Description: "市场部", IsDelete: 0},
		{Fid: 0, Name: "人力资源部", CreateTime: utils.TimeFormatter(time.Now()), LeaderId: 0, Status: 1, Description: "人力资源部", IsDelete: 0},
		{Fid: 0, Name: "财务部部", CreateTime: utils.TimeFormatter(time.Now()), LeaderId: 0, Status: 1, Description: "财务部", IsDelete: 0},
		{Fid: 0, Name: "客户服务部", CreateTime: utils.TimeFormatter(time.Now()), LeaderId: 0, Status: 1, Description: "客户服务部", IsDelete: 0},
		{Fid: 0, Name: "教学部", CreateTime: utils.TimeFormatter(time.Now()), LeaderId: 0, Status: 1, Description: "教学部", IsDelete: 0},
	})
}
